import java.util.Iterator;
import java.util.function.Consumer;

/**
 * Created by asus on 2017/10/22.
 */
public class ArrayIterator<T> implements Iterator<T> {
     int DEFAULT_CAPACITY=20;
     T[] myArray= (T[])(new Object[DEFAULT_CAPACITY] );
     int size=0;
     int cursor=0;
    @Override
    public void remove() {

    }

    @Override
    public void forEachRemaining(Consumer<? super T> action) {

    }

    @Override
    public boolean hasNext() {

        return cursor<size;
    }

    @Override
    public T next() {
            if (hasNext()){
                return myArray[cursor++];
            }
            else
                return null;

    }
    public void add(T element){
        myArray[size]=element;
        size++;
    }
    public int size(){
        return size;
    }
}
